#ifndef TABLE_H
#define TABLE_H
/* table.h
 *  A table is basically a set of name,value pairs.
 */
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>

 typedef struct ctblentry { 
	 char* name;
	 int   size;
	 void* data;

	/* add the full array of types */
	 enum ctblentrytype {EMPTY, INTEGER, CSTRING, FGROUP, MIXTYPE} type; 
 } entry; 

 typedef struct ctbl* table; 
 struct ctbl {
	entry* entries;                           /* Pointer to object array */
	int    ctblcap;                           /* Capacity of pool        */
	int    ctblsize;                          /* Current number of elems */
 };

 typedef struct lookup_result {
	int index;
	int type;
} lookup_result;

 typedef struct rh_address{
	void* addr;
	size_t size;
} rh_address;
	
 table table_init(size_t capacity);
 int   table_insert(table t, char* key, int typename, void* value, size_t vsz);
 int   table_assign(table t, char* key, void* value, size_t vsz);
 lookup_result*   table_includes(table t, char* key);
 rh_address* table_retrieve(table t, int offset);
 void* table_at(table t, int index);
 void  table_destroy(table t);
 void  table_print(table t);
#endif
